#ifndef __JOIN_INFO_H__
#define __JOIN_INFO_H__

/*!
 * Maxium channels to be saved
 */
#define MAX_SAVE_CHANNELS  8

/*!
 * Node join para struct
 */
typedef struct
{
    uint32_t NetID;
    uint32_t DevAddr;
    uint8_t NwkSKey[16];
    uint8_t AppSKey[16];
    uint32_t ReceiveDelay1;
    uint32_t ReceiveDelay2;
    ChannelParams_t ChannelList[MAX_SAVE_CHANNELS];
    uint8_t Channel_index[MAX_SAVE_CHANNELS];
    uint32_t Fcnt;
} Join_info_t;

/*!
 * Node join para struct
 */
typedef struct
{
    uint32_t Store_flg;
    Join_info_t JoinInfo;
} Join_info_store_t;

/*!
 * Get node join information that contained in join-accept messagg by server to node
 *
 * \remark It called when node is join network via 'OTAA'
 *
 * \param Join information
 */
void Get_join_info(Join_info_t *Join_info);

/*!
 * Manual to join the network,Not use 'OTAA' procedure
 *
 * \param Join information
 */
void Set_join_info(Join_info_t *Join_info);

/*!
 * Store node join information to flash
 */
void Store_join_info(Join_info_store_t *Join_info_store);

/*!
 * Read node join information from flash
 *
 * \retval If the flash has join information function return ture,
 *         Otherwise return false
 */
bool Read_join_info(Join_info_store_t *Join_info_store);
#endif

